import React, { Component, lazy, Suspense } from 'react';

import { Route, Switch, Redirect } from 'react-router-dom'

// 引入loading组件
import Loading from '@/components/Loading'
// 使用lazy方式懒加载引入组件
const Welcome = lazy(() => import('@/views/dashboard/Welcome'))
const User = lazy(() => import('@/views/dashboard/user/Index'))
const Film = lazy(() => import('@/views/dashboard/film/Index'))
const Cinema = lazy(() => import('@/views/dashboard/cinema/Index'))
const College = lazy(() => import('@/views/dashboard/college/Index'))



class Admin extends Component {
    render() {
        return (
            <Suspense fallback={<Loading></Loading>}>
                <Switch>
                    {/* react v5的路由的中,二级路由path 需要将一级路由的path拼上 */}
                    <Route path='/dashboard/welcome' component={Welcome}></Route>
                    <Route path='/dashboard/user/index' component={User}></Route>
                    <Route path='/dashboard/film/index' component={Film}></Route>
                    <Route path='/dashboard/cinema/index' component={Cinema}></Route>
                    <Route path='/dashboard/college/index' component={College}></Route>
                    <Redirect from='/dashboard' to='/dashboard/welcome' exact></Redirect>
                </Switch>
            </Suspense>
        );
    }
}

export default Admin;
